Name: 'PopupSeparatorMenuItem',
Extends: PopupBaseMenuItem,
- _init: function () {
+ _init: function (text) {
this.parent({ reactive: false,
can_focus: false});
+ this._box = new St.BoxLayout();
+ this.addActor(this._box, { span: -1, expand: true });
+
+ this.label = new St.Label({ text: text || '' });
+ this._box.add(this.label);
+ this.actor.label_actor = this.label;
+
this._separator = new Separator.HorizontalSeparator({ style_class: 'popup-separator-menu-item' });
- this.addActor(this._separator.actor, { span: -1, expand: true });
+ this._box.add(this._separator.actor, { expand: true });
}
});
},
_updateSeparatorVisibility: function(menuItem) {
+ if (menuItem.label.text)
+ return;
+
let children = this.box.get_children();
let index = children.indexOf(menuItem.actor);
const PopupMenu = imports.ui.popupMenu;
+function stripMnemonics(label) {
+ if (!label)
+ return '';
+
+ // remove all underscores that are not followed by another underscore
+ return label.replace(/_([^_])/, '$1');
+}
+
+const RemoteMenuSeparatorItemMapper = new Lang.Class({
+ Name: 'RemoteMenuSeparatorItemMapper',
+
+ _init: function(trackerItem) {
+ this._trackerItem = trackerItem;
+ this.menuItem = new PopupMenu.PopupSeparatorMenuItem();
+ this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
+ this._updateLabel();
+
+ this.menuItem.connect('destroy', function() {
+ trackerItem.run_dispose();
+ });
+ },
+
+ _updateLabel: function() {
+ this.menuItem.label.text = stripMnemonics(this._trackerItem.label);
+ },
+});
+
const RemoteMenuItemMapper = new Lang.Class({
Name: 'RemoteMenuItemMapper',
},
_updateLabel: function() {
- let label = this._trackerItem.label;
- // remove all underscores that are not followed by another underscore
- label = label.replace(/_([^_])/, '$1');
- this._label.text = label;
+ this._label.text = stripMnemonics(this._trackerItem.label);
},
_updateSensitivity: function() {
let item;
if (trackerItem.get_is_separator()) {
- item = new PopupMenu.PopupSeparatorMenuItem();
+ let mapper = new RemoteMenuSeparatorItemMapper(trackerItem);
+ item = mapper.menuItem;
} else {
let mapper = new RemoteMenuItemMapper(trackerItem);
item = mapper.menuItem;